package com.jianshuai.service.impl;

import com.jianshuai.domain.User;
import com.jianshuai.mapper.UserMapper;
import com.jianshuai.service.IUserService;
import com.jianshuai.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public AjaxResult add(User user) {
        userMapper.add(user);
        return new AjaxResult();
    }

    @Override
    public AjaxResult delete(Long userId) {
        userMapper.delete(userId);
        return new AjaxResult();
    }

    @Override
    public AjaxResult getUserById(Long userId) {
        User user = userMapper.getUserById(userId);
        return AjaxResult.me().setData(user);
    }

    @Override
    public AjaxResult update(User user) {
        userMapper.update(user);
        return new AjaxResult();
    }

    @Override
    public User getId(Long userId) {
        return userMapper.getUserById(userId);
    }
}
